{% extends 'layout.html' %}
{% load static %}

{% block content %}
    <div class="table">
        <div class="add_btn">
            <a href="{% url 'policy_add' %}" class="btn btn-success">
                <i class="fas fa-plus-circle"></i>
                <span> 添加</span>
            </a>
        </div>

        <table class="table table-bordered">
            <thead>
            <tr>
                <th>ID</th>
                <th>购买数量</th>
                <th>价格</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            {% for item in pager.sub_queryset %}
                <tr row-id="{{ item.id }}">
                    <th scope="row">{{ item.id }}</th>
                    <td>{{ item.count }}</td>
                    <td>{{ item.price }}</td>
                    <td>
                        <a href="{% url 'policy_edit' pk=item.id %}" class="btn btn-xs btn-primary">编辑</a>
                        <a href="#" class="btn btn-xs btn-danger btn-delete" cid="{{ item.id }}">删除</a>
                    </td>
                </tr>
            {% endfor %}
            </tbody>
        </table>

        {% include 'include/delete_modal.html' %}

        <nav aria-label="Page navigation">
            <ul class="pagination">
                {{ pager.html }}
            </ul>
        </nav>
    </div>
{% endblock %}

{% block js %}
    <script>
        var DELETE_ID;
        var DELETE_URL = "{% url 'policy_delete' %}"
    </script>
    <script src="{% static 'js/delete_modal.js' %}"></script>
{% endblock %}
